<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8" />
	<title>Document</title>
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	
	<link rel="stylesheet" type="text/css" href="../../css/mui.min.css"/>
	<style type="text/css">
			.mui-ellipsis-2{
				-webkit-line-clamp: 3;
				font-size: 17px ;
				text-indent: 0px;
				/* font-weight: bold; */
			}
			
			.list-detail{
				margin-top: 5px;
				font-size: 15px;
				color: darkgrey;
				text-indent: 0px;
			}
			li{
				margin-top: 8px;
				padding-bottom: 2px;
				margin: 1px;
				
				border-width: 0px;
				border-color: #e0e0e0;
				border-style: solid;
				border-radius: 5px;
			}
			
			/* 清除列表选中时背景色 */
			.mui-table-view-cell > a:not(.mui-btn).mui-active {
				background-color: #fff;
			}
			
			.mui-table-view:before ,.mui-table-view:after{
				height: 0px;
				
			}
			
			.mui-table-view-cell:after {
		/* 	  position: absolute;
			  right: 0;
			  bottom: 0;
			  left: 15px; */
			  height: 1px;
	/* 		  content: '';
			  -webkit-transform: scaleY(.5);
			  transform: scaleY(.5);
			  background-color: #c8c7cc; */
			}
	
			.avatar-icon{
				height : 20px;
				width : 20px 
				/* border-radius: 50%; */
				margin-top: 2px;
				float: left;
			}
			
			.mui-table-view-cell{
				margin-top: 0px;
				margin-left: 0px;
				margin-right: 0px;
			}
			
			.dislike-icon{
				width: 25px;
				height: 25px;
				float: right;
				margin-right: 8px;
				margin-top: 10px;
				padding: 8px;
			}
			
		</style>
		
</head>
<body>
	
<div class="mui-content">
	<div id="sh-list-id" style="margin-top: 0px;">
		<ul class="mui-table-view" id="table-view-id" style="padding-top:0px;" v-cloak >	
			<li :id="item.pid" class="mui-table-view-cell"  v-for="item in items">
				<a @tap="tableViewDidClicked(item)">
					<div class="mui-media-body">
						<div class="mui-ellipsis-2">
							{{getContent(item)}}
							<!-- {{item.content.title}} -->
						</div>
						
						<div class="list-detail mui-ellipsis-2">
							{{item.content.content}}
						</div>
					</div>
					
					<img  v-if="item.flag" v-bind:src="item.imageUrl" alt="" v-bind:style="{width:item.width + 'px' , height:item.width + 'px' , marginTop:'10px' , borderRadius:'5px'}" >
					
					<div>
						<div style="">
							<img v-bind:src="item.user.avatar_thumb || '../../images/default_avatar.png'" class="avatar-icon"  style="border-radius: 50%;width:25px;height: 25px; margin-top: 8px;" >
							<div style="display: inline-block;color: #666;font-size: 13px;margin-left: 5px;margin-top: 12px;margin-bottom: 0px;height: 20px;">
								{{item.user.name}} 
							</div>
							<div style="display: inline-block;color: #666;font-size: 13px;margin-left: 10px;">
								{{item.postDateFormatter}} <span style="margin-left: 8px;font-size: 12px;">阅读{{item.readCnt}}</span>
							</div>
							<!-- <img src="../../images/dislikeicon_details@2x.png" alt="" class="dislike-icon" > -->
							<a v-on:click.stop="operationBtnAction(item)" style="float: right;margin-right: 8px;font-size: 12px;background-color: orangered;margin-top: 10px;padding: 1px 8px;border-radius: 5px; color: white;">待审核</a>
							
						</div>
					</div>
				</a>
			</li>
		</ul>
		
	</div>
</div>

<script src="../../js/mui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/p/api.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/p/vue.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/p/date.formatter.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/p/open.page.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/p/user.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/p/hud.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/p/base-data.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/p/tt.refresh.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/p/user-operation.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
	mui.init({
		pullRefresh: {
			container: '#sh-list-id',
			down: {
				style: 'circle',
				// offset: '1px',
				auto: false,
				callback: pulldownRefresh
			},
			up: {
				contentrefresh: '正在加载...',
				callback: loadMoreData
			}
		}
});
	
		var baseinfo = new Vue({
		el:'#top-userinfo',
		data:{
			item:{}
		},
		
		methods:{
			isMySelf:function(){
				var user = this.item;
				return user['user_id'] == getLoginUid();
			}
		}
	})
	
	
	var ztlist = new Vue({
		el: '#table-view-id',
		data: {
			items: []
		},
		computed:{
			user_name:function(){
				var user = this.item;
				var uname = user["name"] || user['nickName'];
				return uname;
			},
			avatar:function(){
				var d = this.item;
				var u_avatar = d['avatar_thumb'] || "../../images/default_avatar.png";
				return u_avatar;
			}
		},
		
		methods:{
			getContent:function(item){
				var _type = item['type'];
				if(homeAvaliableItemType.indexOf(_type) == -1){
					return item['content']['title'];
				}
				
				return item['content'];
			}
		}
	});
	
	
	mui.plusReady(function () {
	   var pars = {
	   	"type":0 ,
		'uid':getLoginUid(),
		'pageNumber':1
	   }
	   
	   	ttRefreshInit('#sh-list-id', sh_url , pars , function(res){
	   			_dataConvert(res);
	   });
	   
	   refreshRequestData();
	})


	
	///数据转化处理
	function _dataConvert(arr){
		if(arr == null || arr.length < 1){return;}
		for (var i = 0; i < arr.length; i++) {
			var d = arr[i];
			var _type = d['type'];
			
			if(homeAvaliableItemType.indexOf(_type) == -1){
				var content = d['content'];
				content = content.replace(/\n/g," ")
				var obj = JSON.parse(content);
				d['content'] = obj;
			}
			
			var postDate = d['postDate'];
			d['postDateFormatter'] = dateUtils.format(postDate);
			
			var uname = d['user']['name'];
			var nick = d['user']['nickName'];
			if(uname == null || uname == ''){d['user']['name'] = nick;}
			
// 			var u_avatar = d['user']['avatar'] || "../../images/default_avatar.png";
// 			d['user']['avatar'] = u_avatar;
// 			
			//添加图片		
			var igStr = d['images'];
			if(igStr != null && igStr.length > 0){
				var igurlArr = igStr.split(',');
				d['imageUrl'] = igurlArr[0];
				d['flag'] = 1;
				var w = (plus.screen.resolutionWidth - 30) / 3.0;
				d['width'] = w;
			}	
		}
		
		// dataSourceArr.push.apply(dataSourceArr ,arr);
		
		//渲染列表
		ztlist.items = arr;
	}
	
	//跳转详情页
	function tableViewDidClicked(item){
		var _category = getItemCategory(item['type']);;
		var h = plus.nativeUI.showWaiting();
		setTimeout(function(){
			h.close();
			item['issh'] = 1;
			openNewPage('../home/home-detail.html', '审帖' , true,{'item':item , 'category':_category});
		} , 500)
		
	}
	
	
function operationBtnAction(item){
	plus.nativeUI.actionSheet({'title':'选择操作' , 'cancel':'取消' , 'buttons':[{'title':'通过'},{'title':'拒绝'},{'title':'删除'}]} , function(e){
		console.log(e.index);
		//console.log(JSON.stringify(item));
		
		if (e.index < 3) {
			var _category = getItemCategory(item['type']);
			var d = {"uid":getLoginUid() ,
			     "pid": item['pid'],
			     "category":_category,
			     "type":1,
				 'status':e.index};
			
			hud_show('正在提交');	 
			api_post(sh_url , d , function(res){
				//删除列表元素
				var l = document.getElementById(item['pid']);
				l.parentNode.removeChild(l);
				
				hud_close('已成功审核');
			} , function(error){
				hud_close(error);
			});	  
		}else{
			USER_OP.deletePost(item);
		}
	})
	
}

</script>
</body>
</html>